a11y: Hack around infinite loops in parent setting
authorBenjamin Otte <otte@redhat.com>
Mon, 3 Oct 2011 15:05:40 +0000 (17:05 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 25 Oct 2011 11:38:36 +0000 (07:38 -0400)
This is kind of a hack to get rid of infinite loops that occur when
child accessibles try to set their parent upon creation but the parent
accessible creates its children in the initialize vfunc. Because in that
case, the parent will not have an accessible set when the child tries to
access it, because it is still initializing itself. Which will cause a
new accessible to be created.

https://bugzilla.gnome.org/show_bug.cgi?id=660687

gtk/gtkwidget.c

index 8ebc2f5dc7d162276a70e2edb69dbc6efb0c0476..8bc8c078364f8cac5962fa38928b135621d1e786 100644 (file)
@@ -12088,19 +12088,27 @@ gtk_widget_real_get_accessible (GtkWidget *widget)
         accessible =
           atk_object_factory_create_accessible (factory,
                                                 G_OBJECT (widget));
+
+        if (priv->accessible_role != ATK_ROLE_INVALID)
+          atk_object_set_role (accessible, priv->accessible_role);
+
+        g_object_set_qdata (G_OBJECT (widget),
+                            quark_accessible_object,
+                            accessible);
       }
     else
       {
         accessible = g_object_new (priv->accessible_type, NULL);
-        atk_object_initialize (accessible, widget);
-      }
 
-    if (priv->accessible_role != ATK_ROLE_INVALID)
-      atk_object_set_role (accessible, priv->accessible_role);
+        if (priv->accessible_role != ATK_ROLE_INVALID)
+          atk_object_set_role (accessible, priv->accessible_role);
 
-    g_object_set_qdata (G_OBJECT (widget),
-                        quark_accessible_object,
-                        accessible);
+        g_object_set_qdata (G_OBJECT (widget),
+                            quark_accessible_object,
+                            accessible);
+
+        atk_object_initialize (accessible, widget);
+      }
   }
   return accessible;
 }